<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>定时任务列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/common.css}">
    <script type="text/javascript" th:src="@{/js/jquery-3.3.1.min.js}"></script>
</head>
<body>
	<div class="main-container">
		<h2>定时任务列表</h2>
		<div class="opt-tools">
			<button type="button" id="add">新建</button>
			<button type="button" id="init">初始化</button>
		</div>
		<table width="100%" cellspacing="0" cellpadding="0" border="1">
			<thead>
				<tr>
					<td>任务名称</td>
					<td>任务状态</td>
					<td>执行计划</td>
					<td>下次运行时间</td>
				</tr>
			</thead>
			<tbody>
				<tr th:each="quartzJob : ${quartzJobs}">
					<td th:text="${quartzJob.jobName}"></td>
					<td th:if="${quartzJob.jobStatus == '01'}">启用</td>
					<td th:if="${quartzJob.jobStatus == '00'}">禁用</td>
					<td th:text="${quartzJob.cronExpression}"></td>
					<td th:text="${quartzJob.nextRuntime}"></td>
				</tr>
			</tbody>
		</table>
	</div>
	<script type="text/javascript">
		$(function(){
			$("#add").on("click", function(){
				window.open("/quartzJob/add");
			});
			
			$("#init").on("click", function(){
				$.get("/quartzJob/init", function(res) {
					if (res.success) {
						window.location.reload();
					} else {
						alert("任务初始化异常！");
					}
				}, "json");
			});
		});
	</script>
</body>
</html>